package com.shigen.file.serializer;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.shigen.file.emuns.YesNoEnum;
import java.io.IOException;

/**
 * 是否的格式化
 *
 * @author shigenfu
 * @date 2022/5/11 4:06 下午
 */
public class YesNoSerializer extends JsonSerializer<Integer> {

  @Override
  public void serialize(Integer integer, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
    if (integer == null || integer < -1) {
      jsonGenerator.writeString("");
    } else {
      jsonGenerator.writeString(YesNoEnum.getDesc(integer));
    }
  }
}
